<template>
  <section v-loading="loading" class="cms-body">
    <div class="cms-list-header flex-between">
      <el-button type="primary" icon="el-icon-plus" @click="routerLink('/message/save','save',0)" v-perms="'/message/save'">添加</el-button>
      <div>
        <el-select v-model="params.msgStatus" @change="goQuery()">
          <el-option label="发布状态" value=""></el-option>
          <el-option label="未发布" value="0"></el-option>
          <el-option label="已发布" value="1"></el-option>
        </el-select>
        <cms-input v-model="params.msgTitle" label="标题"></cms-input>
        <el-button @click="goQuery()">查询</el-button>
      </div>
    </div>

    <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">

      <el-table-column type="selection" width="65" align="right"></el-table-column>

      <el-table-column prop="id" label="ID" width="50" align="center"></el-table-column>

      <el-table-column prop="msgTitle" label="标题" align="center"></el-table-column>

      <el-table-column prop="msgStatus" label="发布状态" align="center">
        <div slot-scope="scope">
          <span v-if="scope.row.msgStatus==false">未发布</span>
          <span v-if="scope.row.msgStatus==true">已发布</span>
        </div>
      </el-table-column>

      <el-table-column prop="sendTime" label="发布时间" align="center"></el-table-column>

      <el-table-column label="操作" align="center">
        <div slot-scope="scope">
          <cms-button type="edit" @click.native="routerLink('/message/update','update',scope.row.id)" v-perms="'/message/update'"></cms-button>
          <cms-button type="delete" @click.native="deleteBatch($api.messageDelete,scope.row.id)" v-perms="'/message/delete'"></cms-button>
        </div>
      </el-table-column>

    </el-table>

    <!-- 表格底部 -->
    <div class="cms-list-footer">
      <!-- cms分页组件 -->
      <cms-pagination :total="total" @change="getPages"></cms-pagination>
    </div>

  </section>
</template>

<script>
  import listMixins from '@/mixins/list'

  export default {
    mixins: [listMixins],
    data() {
      return {
        params: {//只需要业务参数
          pageNo: 1,
          pageSize: 10,
          msgStatus: '',
          msgTitle: ''
        },
      };
    },
    methods: {
      goQuery() {
        this.getTableData(this.params);
      }
    },
    created() {
      this.initTableData(this.$api.messagePageList, this.params);
    }
  };
</script>

<style>

</style>
